<?php

/**
 * 餐厅分店编辑
 * 
 * @copyright xinwei
 * @since 2012-04-25
 */

include_once($_SERVER["DOCUMENT_ROOT"] . "/core/inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/core/admin.inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/include/foodv2/inc.php");

$g_cgival = array();
$g_pro = array();
$g_show = array();


function check_cgi_pro()
{
	global $g_cgival, $g_pro, $g_show;
	
	//关键词
	cgi::get($g_cgival["rstrt_id"], "rstrt_id", 0);
	$g_cgival["rstrt_id"] = intval($g_cgival["rstrt_id"]);
}

function get_data()
{
	global $g_cgival, $g_pro, $g_show,$config;
	
	$db = new db_web_rstrt();
	$db_cname = new db_web_rstrt_cname();
	$db_tag = new db_food_tag();
	$db_area = new db_eat_area();
	$user_db = new db_food_user();
	
	$rstrt_tag = new db_web_rstrt_tag();
	
	// 拿到当前站点的site_id
	$site_id = admin::admin_get_user_site_id();
	
	//获取当前site_id的城市
	$g_show["city"] = $db_area->admin_get_city_by_site_id($site_id);
	
	//菜系
	$styleArr = $db_tag->admin_shangjia_search($site_id, '菜系', '', 1, -1, 1, 10000);
	
	//风味
	$flavorArr = $db_tag->admin_shangjia_search($site_id, '食尚', '', 1, -1, 1, 10000);
	

	// 按条件获取分店列表
	$info = $db->get_list_shops_by_rstrt_id($g_cgival["rstrt_id"]);
	
	if(empty($info))
		throw new Exception("该餐厅没有分店");

	$g_show["data"]["rstrt_list"] = $info;
	

	//当前参数输出到页面	
	$g_show['args'] = $g_cgival;
	$g_show['args']['city'] = $config["site_name"][$site_id]; 
}

$g_show["error"] = 0;
$g_show["errmsg"] = '';
try
{
	admin_check_login();
// 	admin_check_user_priv("foodv2/album_list.php");
	
	check_cgi_pro();
	get_data();
}
catch(Exception $e)
{
	$g_show["error"] = 1;
	$g_show["errmsg"] = $e->getMessage();
}

show_pro();
exit;


function show_pro()
{
	global $g_cgival, $g_pro, $g_show;
	if(isset($_GET['debug']))
		print_r($g_show);
	$smarty = p_get_smarty ();
	$smarty->assign ( 'g_show', $g_show );
	$smarty->display ( "foodv2/rstrt/rstrt_chain.html" );
}

?>